<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <script>
    let ws = new WebSocket('ws://localhost:3000/test');
    // 打开WebSocket连接后立刻发送一条消息:
    ws.on('open', function () {
      console.log(`[CLIENT] open()`);
      ws.send('Hello!');
    })
    // 响应收到的消息:
    ws.on('message', function (message) {
      console.log(`[CLIENT] Received: ${message}`)
    })
  </script>
</body>
</html>